-
-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anvil Chunk saving #401
base: master
Are you sure you want to change the base?
Anvil Chunk saving #401
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some reviews to the code. Would like to see some unit tests too, basically create a fake region with (1, 2 ... all) chunks getting serialized. Then immediately de-serialize and verify all data is the same. With all compressions also.
@@ -141,41 +186,300 @@ impl ChunkReader for AnvilChunkReader { | |||
out | |||
}; | |||
|
|||
// TODO: check checksum to make sure chunk is not corrupted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was a checksum implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that i know, this was lucas comment
) | ||
}); | ||
|
||
region_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, the pad should make the whole file a multiple of 4096, not just add 4096. It should be len(header) + len(bytes) + len(pad) % 4096 == 0
} | ||
|
||
sections.push(ChunkSection { | ||
y: i as i8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be -y heights, but i
is a usize. Should there be a start_y passed in?
@@ -189,16 +176,22 @@ impl Level { | |||
self.chunk_watchers.shrink_to_fit(); | |||
} | |||
|
|||
pub fn write_chunk(&self, _chunk_to_write: (Vector2<i32>, Arc<RwLock<ChunkData>>)) { | |||
//TODO | |||
pub async fn write_chunk(&self, chunk_to_write: (Vector2<i32>, Arc<RwLock<ChunkData>>)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some kind of file lock so multiple threads don't try to write to the same file at the same time/read while the file is being written
For some reason currently loading vanilla chunks does not work when writing, when early return in the |
Looking for help, Mojang did a great job making this Format really complicated. If someone wants to help i would really appreciate it. |
Description
Add Chunk saving via the Anvil format.
More details on how the formats works can be found at https://minecraft.fandom.com/wiki/Region_file_format
Testing
Checklist
Things need to be done before this Pull Request can be merged.
Please follow our Coding Guidelines